#include "../include/User.h"
#include <string>

using namespace eGaduLib;
using namespace std;


User::User(void)
{
	name = 0;
	desc = 0;
	uin = 0;
	type = 0;
	status = 0;
}

User::User(int _uin, char *_name, int _type)
{
    name = 0;
	desc = 0;
	uin = 0;
	type = 0;
	status = 0;

	set(_uin, _name, _type);
}

User::~User(void)
{
}

void User::set(int _uin, char *_name, int _type)
{
	type = _type;
	uin = _uin;
	setName(_name);
}

void User::setType(int _type)
{
	type = _type;
}

void User::setUin(int _uin)
{
	uin = _uin;
}

void User::setName(char *_name)
{
	int len = strlen(_name);
	if(len > 0)
	{
		name = new char[len + 1];
		strcpy(name, _name);
	}
}

void User::setStatus(int _status)
{
	status = _status;
}

void User::setDesc(char *_desc)
{
	int len = strlen(_desc);
	if(len > 0)
	{
		desc = new char[len + 1];
		strcpy(desc, _desc);
	}
}

int User::getType()
{
	return type;
}

int User::getUin()
{
	return uin;
}

char *User::getName()
{
	return name;
}

int User::getStatus()
{
	return status;
}

char *User::getDesc()
{
	return desc;
}

void User::release()
{
    if(name != 0)
        delete [] name;
    if(desc != 0)
        delete [] desc;

    uin = 0;
    status = 0;
    type = 0;
    name = 0;
    desc = 0;
}
